import { onMounted, onUnmounted, ref } from 'vue'

function useMouse() {
    const x = ref(0)
    const y = ref(0)
    const move =  (e) => { 
        console.log(e.x, e.y) 
        x.value = e.x
        y.value = e.y
    }
    onMounted(()=>{
        document.addEventListener('mousemove',move)
    })
    
    onUnmounted( () => {
        document.removeEventListener('mousemove',move)
    })
    
    return { x, y }
}

export default useMouse